import { Allow, IsBoolean, IsDefined, IsInt, Length } from 'class-validator';

export class Ooo {
  // @IsDefined()
  @Length(10, 20, {
    message({ targetName, property, value, constraints }) {
      return `${targetName} 类的 ${property} 属性的值 ${value} 不满足约束: ${constraints}`;
    },
  })
  name: string;

  @Allow()
  @IsInt({
    message() {
      return '年龄必须为整数';
    },
  })
  age: number;

  @Allow()
  @IsBoolean()
  sex: boolean = false;
  hobbies: Array<string>;
}
